package cn.edu.seig.textbook.controller;

import cn.edu.seig.textbook.domain.pojo.Users;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Calendar;

@Controller
class LoginController {

    @RequestMapping("/toLoginPage")
    public String toLoginPage(HttpServletRequest request) {
        request.getSession().setAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

    @GetMapping("/login")
    public String login(HttpServletRequest request) {
        request.setAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }
    @GetMapping("/logout")
    public String logout() {
        return "login";
    }

    @PostMapping("/login")
    String login(Users user, HttpServletRequest request) {
        System.out.println(user);
        return "index";
    }
}